#!/bin/bash

APP_NAME=$1
if [ "$APP_NAME" == "" ]; then
    echo "must input app_name"
    exit 24
fi



## 编译
echo "正在编译$APP_NAME"
scripts/shell/build.sh linux $APP_NAME > /dev/null
if [ $? == 0 ]; then
    echo "上传至服务器"
    scp bin/"$APP_NAME" root@118.190.45.101:/tmp/
    if [ $? == 0 ]; then
        echo "正在部署"
        ssh root@118.190.45.101 "mv -f /tmp/$APP_NAME /Project/$APP_NAME/ && bash /Project/$APP_NAME/restart.sh $APP_NAME"
        if [ $? != 0 ]; then
            echo "部署失败"
        fi
        
    else
        echo "上传失败"
    fi

else
    echo "编译失败"

fi